package com.service.match.common.enums;

import lombok.Getter;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Optional;
import java.util.stream.Stream;

public class TradingSpotEnum {

    public enum TradeType {
        BUY(1, "买入"),
        SELL(2, "卖出"),
        ;

        @Getter
        private Integer code;
        @Getter
        private String name;

        TradeType(Integer code, String name) {
            this.code = code;
            this.name = name;
        }
        public static Optional<TradeType> of(Integer code) {
            return Arrays.stream(values()).filter(i -> i.code.equals(code)).findFirst();
        }
    }

    public enum PriceType {
        LIMIT(1, "限价委托"),
        MARKET(2, "市价委托"),
        ;

        @Getter
        private Integer code;
        @Getter
        private String name;

        PriceType(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

        public static Optional<PriceType> of(Integer code) {
           return Arrays.stream(values()).filter(i -> i.code.equals(code)).findFirst();
        }
    }

    public enum Status {
        CREATED(-1, "创建成功"),
        SEND_ENGINE(0, "发送至撮合引擎成功"),
        INCOMPLETE(1, "非完全交易"),
        COMPLETED(2, "交易完全"),
        CANCEL(3, "交易撤销"),
        ;

        @Getter
        private Integer code;
        @Getter
        private String name;

        Status(Integer code, String name) {
            this.code = code;
            this.name = name;
        }

    }


}
